package com.jiang.专题.队列.Q0306;

import java.util.LinkedList;
import java.util.Queue;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/03/03 1:35
 */
class AnimalShelf {
    Queue<int[]> q;

    public AnimalShelf() {
        q = new LinkedList<>();
    }

    public void enqueue(int[] animal) {
        q.offer(animal);
    }

    public int[] dequeueAny() {
        return q.isEmpty() ? new int[]{-1, -1} : q.poll();
    }

    public int[] dequeueDog() {
        for (int[] v : q) {
            if (v[1] == 1) {
                q.remove(v);
                return v;
            }
        }
        return new int[]{-1, -1};
    }

    public int[] dequeueCat() {
        for (int[] v : q) {
            if (v[1] == 0) {
                q.remove(v);
                return v;
            }
        }
        return new int[]{-1, -1};
    }
}
